package co.fitstart.entity.market;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;

import co.fitstart.entity.market.template.MarketMonthlyCoursewareTemplate;

/**
 * 
 * @author dan
 *
 */
@Entity
@Table(name = "market_monthly_courseware")
@JsonIgnoreProperties(value={"hibernate_lazy_initializer","handler","fieldHandler"})
public class MarketMonthlyCourseware {
    
    @Id
    @GeneratedValue
    private Long id;
    
    /** 状态 */
    private CoursewareStatus status;
    
    @ManyToOne(fetch = FetchType.LAZY, optional = false)
    private MarketCourseRound courseRound;
    
    @ManyToOne(fetch = FetchType.LAZY, optional = false)
    private MarketMonthlyCoursewareTemplate template;
    
    @Column(name = "is_disabled")
    private boolean disabled;
    
    /**
     * The default constructor
     */
    public MarketMonthlyCourseware() {
        
    }
    
    /**
     * 
     * @param template
     * @param courseRound
     */
    public MarketMonthlyCourseware(MarketMonthlyCoursewareTemplate template, MarketCourseRound courseRound) {
        this.status = template.getSorting() == 1 ? CoursewareStatus.SIGNINING : CoursewareStatus.PREPARE;
        this.courseRound = courseRound;
        this.template = template;
        this.disabled = false;
        
    }
    
    /**
     * 
     * @param status
     * @return
     */
    public MarketMonthlyCourseware changeStatus(CoursewareStatus status) {
        this.status = status;
        return this;
    }

    /**
     * @return the id
     */
    public Long getId() {
        return id;
    }

    /**
     * @return the status
     */
    public CoursewareStatus getStatus() {
        return status;
    }

    /**
     * @return the courseRound
     */
    public MarketCourseRound getCourseRound() {
        return courseRound;
    }

    /**
     * @return the template
     */
    public MarketMonthlyCoursewareTemplate getTemplate() {
        return template;
    }

    /**
     * @return the disabled
     */
    public boolean isDisabled() {
        return disabled;
    }

    /**
     * @param id the id to set
     */
    public void setId(Long id) {
        this.id = id;
    }

    /**
     * @param status the status to set
     */
    public void setStatus(CoursewareStatus status) {
        this.status = status;
    }

    /**
     * @param courseRound the courseRound to set
     */
    public void setCourseRound(MarketCourseRound courseRound) {
        this.courseRound = courseRound;
    }

    /**
     * @param template the template to set
     */
    public void setTemplate(MarketMonthlyCoursewareTemplate template) {
        this.template = template;
    }

    /**
     * @param disabled the disabled to set
     */
    public void setDisabled(boolean disabled) {
        this.disabled = disabled;
    }

}
